#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
#define int long long
const int N = 1e6 + 10;
bool st[N];
int l , r;
int cnt , p[N];
bool ret[N];

void get_prime()
{
    int n = sqrt(r);
    for(int i = 2;i <= n;i ++)
    {
        if(!st[i]) p[++ cnt] = i;
        for(int j = 1;p[j] * i <= n;j ++)
        {
            st[p[j] * i] = true;
            if(i % p[j] == 0) break;
        }
    }
}   
signed main()
{
    cin >> l >> r;
    get_prime();
    l = l == 1 ? 2 : l;
    for(int i = 1;i <= cnt;i ++)
    {
        int x = p[i];
        for(int j = max(x * 2 , (l + x - 1) / x * x);j <= r;j += x)
        {
            ret[j - l] = true;
        }
    }
    int sum = 0;
    for(int i = l;i <= r;i ++)
    {
        if(!ret[i - l]) sum ++;
    }
    cout << sum << endl;
    return 0;
}